﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;

namespace Gundam_2._0_Alpha.src
{
    public class Stun:BuffAction
    {
        public Stun(Character c, bool persistant, int row, int colEnd, int count, int lockoutLevel, string name, int duration, bool isBuff)
            : base(c, persistant, row, colEnd, count, lockoutLevel, name, duration, false)
        {
            if (!c.Invunerable)
                IsActive = true;
        }

        public override void DoAction(GameController gc)
        {
            if (Core.TimerTicks(timer) == 0)
            {
                GlobalConst.Utils.ActivateAnimationRow(c.ObjectSprite, row + c.offSetSpriteRow(), colEnd, count);
                foreach (Ability a in c.CurrentSet.SetOfAbilities)
                    if (!a.AbilityAction.Immune)
                        a.AbilityAction.Reset(gc);
                c.GlobalLockout = true;
                Core.StartTimer(timer);
            }

            if (Core.TimerTicks(timer) > duration || c.Invunerable)
                Reset(gc);
        }

        public override void Reset(GameController gc)
        {
            IsActive = false;
            int count = 0;
            foreach (BuffAction b in c.Buffs)
                if (b.Name == this.Name)
                    count++;
            if (count == 1)
                c.GlobalLockout = false;
        }
    }
}
